package com.zh.note.huawei.onehundred.自动曝光;

import java.util.Arrays;

/**
 * @Author: zhanghuan
 * @date: 2023/8/5 12:05
 * @description: create it
 */
public class Main {
    public static void main(String[] args) {

        // Scanner sc = new Scanner(System.in);
        // String input = sc.nextLine();
        // String input = "0 0 0 0";
        // String input = "1 2 3 4";
        String input = "129 130 129 130";
        String[] strs = input.split(" ");
        int[] nums = Arrays.stream(strs).mapToInt(Integer::parseInt).toArray();
        int res = 0;
        int minValue = Integer.MAX_VALUE;
        for (int i = -127; i <= 128; i++) {
            int sum = 0;
            for (int j = 0; j < nums.length; j++) {
                int temp = nums[j] + i;
                if (temp > 255) {
                    temp = 255;
                }
                if (temp < 0) {
                    temp = 0;
                }
                sum += temp;
            }
            if (minValue > Math.abs(128 * nums.length - sum)) {
                res = i;
                minValue = Math.abs(128 * nums.length - sum);
            }


        }
        System.out.println(res);

    }
}
